package cn.easybuy.bizImpl;

import cn.easybuy.biz.UserBiz;
import cn.easybuy.dao.UserDao;
import cn.easybuy.daoImpl.UserDaoImpl;
import cn.easybuy.entity.User;

import java.sql.SQLException;
import java.util.List;

public class UserBizImpl implements UserBiz {
    private UserDao userDao=new UserDaoImpl();
    @Override
    public boolean addUser(User user) {
        int result=0;
        try {
            result=userDao.addUser(user);
            if(result==1){
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean logoffUser(User user) {
        int result=0;
        try {
            result=userDao.logoffUser(user);
            if(result==1){
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public User loginUser(User user) {
        User us=null;
        try {
            us=userDao.loginUser(user);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return us;
    }

    @Override
    public List<User> listAll() {
        List<User> users=null;
        try {
            users=userDao.listAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return users;
    }
}
